﻿using System.Collections.Generic;

namespace DesignPattern.com.observer {
    /// <summary>
    /// 主题
    /// </summary>
    public abstract class ISubject {
        private readonly List<IObserver> _obList = new List<IObserver>();

        public void Attach(IObserver obv){
            _obList.Add(obv);
        }

        public void Detach(IObserver obv){
            _obList.Remove(obv);
        }

        public void Notify(){
            _obList.ForEach(obv => obv.Update());
        }
    }
}